var $;
var layer;
var table;

    layui.use(['table', 'layer'], function () {
        table = layui.table;
        $=layui.jquery;
        layer=layui.layer;

        selJournal();

        //查询登录日志
        function selJournal(){
            var id= $("#courseId").val();
            $.post("/tea/selJournal", {id: id}, function (res) {
                if (res.code>-1) {
                    getTab(res.obj);
                } else {
                    layer.msg("数据加载失败", {icon: 2});
                }
            });
        }


        function getTab(data) {
            table.render({
                elem: '#tabId',
                data: data
                , title: '课程日志表'
                , cols: [[
                    {field: 'id', title: '课程编号', width: 86},
                    {field: 'courseName', title: "课程名称"},
                    {title: '销售价格',templet(da){
                            return "<p><span>原价："+da.coursePrice+"元 </span>" +
                                "<span>现价："+da.courseNprice+"元</span></p>";
                        }},
                    {field:'courseStatus', title:'课程状态', width:86,templet(da){
                            if(da.courseStatus==2){
                                return "<p>已上架</p>";
                            }else if(da.courseStatus==3) {
                                return "<p>未上架</p>";
                            }
                        }},
                    {field:'courseCstatus', title:'审核状态', width:86,templet(da){
                            if(da.courseCstatus==3){
                                return "<p>未审核</p>";
                            }else if(da.courseCstatus==4){
                                return "<p>审核中</p>";
                            }else if(da.courseCstatus==5){
                                return "<p>审核失败</p>";
                            }else if(da.courseCstatus==6){
                                return "<p>审核通过</p>";
                            }
                        }},
                    {title:'操作信息',templet(da){
                        var updateDate=settime(da.updateDate);
                        return "<p><span>"+da.updateName+" </span><span>"+updateDate+"</span></p>"
                    }}
                ]]
            });
        };

        /*日期转换格式*/
        function settime(da){
            var date=new Date(da);
            var year=date.getFullYear();
            var month=date.getMonth()+1;
            var day=date.getDate();
            var hours=date.getHours();
            var mm=date.getMinutes();
            var s=date.getSeconds();
            return year+'-'+add(month)+'-'+add(day)+' '+add(hours)+':'+add(mm)+':'+add(s);
            //return year+'-'+month+'-'+day+' '+hours+':'+mm+':'+s;
        };
        function add(time){//给非整数添0
            return time<10?'0'+time:time;
        };
    });
